package com.wanglei.controller;

import com.wanglei.annotation.SystemLog;
import com.wanglei.domain.ResponseResult;
import com.wanglei.domain.entity.User;
import com.wanglei.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/userInfo") //查看用户信息
    public ResponseResult getUserInfo(Long userId){
        return userService.userInfo(userId);
    }

    @PutMapping("/userInfo") //修改用户信息
    @SystemLog(businessName = "更新用户信息") //自定义注解 实现aop 方法增强
    public ResponseResult updateUserInfo(@RequestBody User user){
        return userService.updateUserInfo(user);
    }

    @PostMapping("/register")
    public ResponseResult register(@RequestBody User user){
        return userService.register(user);
    }

}
